package com.dlyk.service.impl;

import com.dlyk.bean.TActivityRemark;
import com.dlyk.constant.Constants;
import com.dlyk.mapper.TActivityRemarkMapper;
import com.dlyk.query.ActivityRemarkQuery;
import com.dlyk.query.BaseQuery;
import com.dlyk.service.ActivityRemarkService;
import com.dlyk.utils.JWTUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {

    @Autowired
    private TActivityRemarkMapper tActivityRemarkMapper;

    /**
     * 提交市场活动备注信息
     * @param activityRemarkQuery
     * @return
     */
    @Override
    public int saveActivityRemark(ActivityRemarkQuery activityRemarkQuery) {
        TActivityRemark tActivityRemark = new TActivityRemark();
        BeanUtils.copyProperties(activityRemarkQuery,tActivityRemark);

        // 设置创建时间
        tActivityRemark.setCreateTime(new Date());
        Integer id = JWTUtils.parseUserFromJWT(activityRemarkQuery.getToken()).getId();
        // 设置创建人
        tActivityRemark.setCreateBy(id);

        // 保存备注信息
        return tActivityRemarkMapper.insertSelective(tActivityRemark);
    }
}
